package com.example.mytayunapi.Mapper;

import com.example.mytayunapi.Entity.collectInfo;
import com.example.mytayunapi.Vo.CollectandProducts;
import com.example.mytayunapi.Vo.VCollectResp;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface collectInfoMapper {

    @Insert("INSERT INTO collect (Product_id, School_degree) VALUES (#{Product_id}, #{School_degree})")
    Integer insertcollectInfo(VCollectResp collectInfo);


    @Select("SELECT p.Product_id, p.Product_image, p.Product_name, p.Product_price, p.Release_status, c.collect_time " +
            "FROM products p " +
            "JOIN collect c ON p.Product_id = c.Product_id " +
            "WHERE c.School_degree = #{schoolDegree}")
    List<CollectandProducts> getProductCollectInfo(String schoolDegree);


    @Delete("DELETE FROM collect WHERE School_degree = #{schoolDegree} AND Product_id = #{productId}")
    Integer deleteProductCollect(@Param("schoolDegree") String schoolDegree, @Param("productId") Long productId);
}
